<template>
	<view class="uni_box home">
		<navbar title='案件咨询'>
		</navbar>
		<view class="content">
			<text class="matit">我的案件</text>
			<view class="nodata" v-if="list == ''">
				<image class="img_kzt" src="/static/img/img_kzt.png"></image>
				<text>暂无案件</text>
			</view>
			<view class="lview">
				<view class="items" v-for="(item,index) in list" :key="index" @click="getDetail(item)">
					<view class="ione">
						提交日期:{{ item.created_at }}
					</view>
					<view class="itwo">
						<text class="tiname">提交人：<text class="">{{item.name}}</text></text>
						<text class="tiname">受理状态：<text class="tival">{{item.status_name}}</text></text>
					</view>
					<view class="cahview">
						<view class="chabtn">查看</view>
					</view>
				</view>
			</view>


			<view class="botview">
				<view class="botbtn" @click="getedit">提交案件</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				page: 1,
				limit: 10,
				last_page: 1,
				status: "loadmore",
				uinfo:{}
			}
		},
		onLoad() {
			// this.getList()
		},
		onShow() {
			this.getClear()
		},
		onReachBottom: function () {
			this.loadmore();
		},
		methods: {
			getedit(){
				this.navrouter("/pages/TPage/AnZixunEdit?type=add");
			},
			getDetail(item){
				this.navrouter("/pages/TPage/AnZixunEdit?id="+item.id+'&type=edit');
			},
			async getList(){//列表数据
				let res = await this.$u.api.caselist({
					limit:this.limit,
				  	page:this.page
				});
				// console.log(res)
				this.uinfo = res
				this.last_page = res.list.last_page;
				let list = res.list.list;
				this.list = this.page == 1 ? list : [...this.list, ...list];	
				if(this.page >= this.last_page){
				  this.status = 'nomore';
				}
				
			},
			loadmore() {
				let page = this.page;
				if (this.status == 'loadmore') {
					this.page++;
					this.getList();
				}
			},
			getClear(){
				this.list = []
				this.page = 1,
				this.status= "loadmore"
				this.getList()
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #F5F5F5;
	}
	.content{
		background-color: #F5F5F5;
		padding-bottom: 130rpx;

		.matit{
			font-family: PingFang SC;
			font-weight: bold;
			font-size: 36rpx;
			color: #333333;
			display: block;
			margin: 40rpx 30rpx;
		}
		.nodata{
			margin: 130rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			width: auto;
			.img_kztz{
				width: 540rpx;
				height: 440rpx;
				margin-bottom: 10rpx;
			}
			text{
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #999999;
			}
		}
		.lview{
			padding: 0 30rpx;
			.items{
				margin-bottom: 20rpx;
				padding: 30rpx;
				background: #FFFFFF;
				border-radius: 10rpx;
				.ione{
					border-bottom: 1rpx solid #EEEEEE;
					padding-bottom: 20rpx;
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 32rpx;
					color: #51565D;
				}
				.itwo{
					margin: 25rpx 0;
					.tiname{
						display: block;
						margin-bottom: 15rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #666666;
					}
					.tival{
						color: #3E65E5;
					}
				}
				.cahview{
					padding-top: 30rpx;
					border-top: 1rpx solid #EEEEEE;
					display: flex;
					flex-direction: row;
					align-items: center;
					justify-content: flex-end;
					.chabtn{
						width: 160rpx;
						height: 60rpx;
						background: #3E65E5;
						border-radius: 10rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #FFFFFF;

					}
				}
			}
		}
		.botview{
			position: fixed;
			width: 100%;
			height: 120rpx;
			background-color: #fff;
			bottom: 0;
			display: flex;
			align-items: center;
			justify-content: center;
			.botbtn{
				height: 88rpx;
				background: #3E65E5;
				border-radius: 20rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #FFFFFF;
				width: 94%;
			}
		}
	}
</style>
